//
//  UIButton-Extension.swift
//  斯威夫特微博
//
//  Created by youyoumacmini3 on 2017/6/30.
//  Copyright © 2017年 youyoumacmini3. All rights reserved.
//

import UIKit

extension UIButton {
    
    convenience init(imageName: String, bgImageName:String) {
        
        self.init()
        
        self.setImage(UIImage(named: imageName), for: UIControlState())
        self.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
        self.setBackgroundImage(UIImage(named: bgImageName), for: UIControlState())
        self.setBackgroundImage(UIImage(named: bgImageName + "_highlighted"), for: .highlighted)
        self.sizeToFit()
    }
    
    convenience init(title: String, size: CGFloat, nomalColor: UIColor, highlightedColor: UIColor ) {
        
        self.init()
        self.setTitle(title, for: UIControlState())
        //self.setTitle(title, for: [])和上面一样的效果
        self.titleLabel?.font = UIFont.systemFont(ofSize: size)
        self.setTitleColor(nomalColor, for: UIControlState())
        self.setTitleColor(highlightedColor, for: .highlighted)
        self.sizeToFit()
    }
    
    
}
